home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / bin / crayola / next / Crayola.m < prev    next >
Text File  |  1993-06-29  |  3KB  |  132 lines

  1.  
  2. #import <stdio.h>
  3.  
  4. #import "geom.h"
  5. #import "color.h"
  6. #import "callbacks.h"
  7. #import "ui.h"
  8. #import "crayola.h"
  9.  
  10. #import "Crayola.h"
  11.  
  12. @implementation Crayola
  13.  
  14. static id selfID, modeMatrixID, currentColorID, colorPanelID;
  15.  
  16. void StdinProc(int fd, void *userDate);
  17.  
  18. - appDidInit:sender
  19. {
  20.   fprintf(stderr, "Doing initialization...\n");
  21.  
  22.   colorPanel = [NXColorPanel sharedInstance:1];
  23.   [colorPanel setHideOnDeactivate:NO];
  24.   [colorPanel setShowAlpha:1];
  25.   [colorPanel setAction:@selector(takeColorFrom:)];
  26.   [colorPanel setTarget:currentColor];
  27.   [self showColorPicker:self];
  28.  
  29.   [queryPanel setAvoidsActivation:YES];
  30.   [colorPanel setAvoidsActivation:YES];
  31.  
  32.   selfID = self;
  33.   modeMatrixID = modeMatrix;
  34.   currentColorID = currentColor;
  35.   colorPanelID = colorPanel;
  36.  
  37.   DPSAddFD(0, StdinProc, NULL, 1);
  38.  
  39.   init();
  40.  
  41.   return self;
  42. }
  43.  
  44. - appWillTerminate:sender
  45. {
  46.   quit();
  47.   return self;
  48. }
  49.  
  50. - Undo:sender
  51. {
  52.   undo();
  53.   return self;
  54. }
  55.  
  56. - showColorPicker:sender
  57. {
  58.   [colorPanel makeKeyAndOrderFront:self];
  59.   return self;
  60. }  
  61.  
  62.  
  63. void StdinProc(int fd, void *userDate) {
  64.   fprintf(stderr, "Got input\n");
  65.   dopipes();
  66. }
  67.  
  68.  
  69. /* Routines called by the common routines. */
  70.  
  71. void uiFreeze() {
  72. }
  73.  
  74. void uiThaw() {
  75. }
  76.  
  77. int whichButton() {
  78.   fprintf(stderr, "button = %d\n", [modeMatrixID selectedRow] * 2 + [modeMatrixID selectedCol]);
  79.   
  80.   return ([modeMatrixID selectedRow] * 2 + [modeMatrixID selectedCol]);
  81. }
  82.  
  83. int uiGet() {
  84.   return (whichButton() == 0 ? 1 : 0);
  85. }
  86.  
  87. int uiSet() {
  88.   return (whichButton() == 1 ? 1 : 0);
  89. }
  90.  
  91. int uiSetAll() {
  92.   return (whichButton() == 2 ? 1 : 0);
  93. }
  94.  
  95.  
  96. int uiEliminateColor() {
  97.   return (whichButton() == 3 ? 1 : 0);
  98. }
  99.  
  100. void uiChangeColor(ColorA *color) {
  101.   [currentColorID setColor:NXConvertRGBAToColor(color->r, color->g, 
  102.                         color->b, color->a)];
  103. }
  104.  
  105. void uiCurrentColor(ColorA *color) {
  106.   NXConvertColorToRGBA([currentColorID color], 
  107.                &color->r, &color->g, &color->b, &color->a);
  108.   fprintf(stderr, "%f %f %f %f\n", color->r, color->g, color->b, color->a);
  109. }
  110.  
  111. int uiQuery(char *ques1, char *ques2, char *ques3, char *res1, char *res2)
  112. {
  113.   char *question;
  114.   int response;
  115.  
  116.   question = OOGLNewNE(char, strlen(ques1) + strlen(ques2) 
  117.                + strlen(ques3) + 3, "uiQuery");
  118.   strcpy(question, ques1);
  119.   strcat(question, " ");
  120.   strcat(question, ques2);
  121.   strcat(question, " ");
  122.   strcat(question, ques3);
  123.   response =  NXRunAlertPanel("Alert", (const char *)question, 
  124.                   (const char *)res2, 
  125.                   (const char *)res1, NULL, NULL);
  126.   OOGLFree(question);
  127.   return response;
  128. }
  129.  
  130.  
  131. @end
  132.